package com.atguigu.patterns.factory.simplefactory;

import com.atguigu.patterns.factory.result.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class StaticUseClient {

	public static void main(String[] args) {
		String orderType = getType();
		Pizza pizza = SimpleFactory.staticCreatePizza(orderType);

		// 输出pizza
		if (pizza != null) { // 订购成功
			pizza.prepare();
			pizza.bake();
			pizza.cut();
			pizza.box();
		} else {
			System.out.println(" 订购披萨失败 ");
		}
	}

	// 写一个方法，可以获取客户希望订购的披萨种类
	private static String getType() {
		try {
			BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
			System.out.println("input pizza 种类:");
			String str = strin.readLine();
			return str;
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}
	}
}
